package com.gjzhao.fmmall.config;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: 熔断监控配置类
 * @Author: gjzhao
 * @Date Created in 2022-02-10 1:54 下午
 */
@Configuration
public class HystrixDashBoardConfig {

    @Bean
    public ServletRegistrationBean getServletRegistrationBean() {

        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        //相当于拦截器
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setName("HystrixMetricsStreamServlet");//servlet名字
        registrationBean.setLoadOnStartup(1); //启动顺序
        registrationBean.addUrlMappings("/hystrix.stream"); //监控盘调用url
        return registrationBean;
    }
}
